﻿using Microsoft.Practices.Unity;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using XiangDongClub.Common;
using XiangDongClub.Infrastructure;

namespace XiangDongClub.Activity
{
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            Log4NetObject.Log4NetInit(AppDomain.CurrentDomain.BaseDirectory + @"Config\log4net.config");

            //IOC配置
            var path = "unity.config";
            IUnityContainer container = UnityContainerHelper.Create(path);
            InstanceLocator.SetLocator(new MyInstanceLocator(container));

            //数据库初始化
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<XDDBContext, Configuration>());
        }
    }
}
